package org.fg.logcommon.config;

import lombok.extern.slf4j.Slf4j;
import org.fg.logcommon.Constant;
import org.slf4j.MDC;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
public class AppInitActions implements InitializingBean {

    @Autowired
    private HeaderCheckInterceptor headerCheckInterceptor;

    @Override
    public void afterPropertiesSet() throws Exception {
        String defaultAppend = "init-append";
        // 增加 append
        headerCheckInterceptor.addAppend(defaultAppend);
        MDC.put(Constant.MDC_KEY, "init-callback");
        log.info("准备完毕！");
        headerCheckInterceptor.closeAppend(defaultAppend);
        MDC.remove(Constant.MDC_KEY);
    }
}
